<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>个人信息</title>
    <link rel="stylesheet" href="css/base.css">
    <link rel="stylesheet" href="css/MyMessage.css">
    <script src="js/jquery-3.6.0.min.js"></script>
</head>
<body>
    <div class="run-bear"></div>
    <div class="top-back">
        <img src="img/theme.jpg" height="400" width="100%"/>
    </div>
    <div class="mid">
        <div class="head">
            <span>个人信息</span>
            <a href="index.html">返回首页</a>
        </div>
        <div class="my-img">
            <div class="circle">
                <img src="img/my-img.png">
            </div>
            <div class="garde">
                用户等级：<span id="level"></span>
            </div>
        </div>
        <div class="info">
            <ul>
                <li>
                    用户名：<span id="user"></span>
                </li>
                <li class="text">
                    <div class="my">
                        <div class="my-ss">
                            我的签名：
                        </div><textarea rows="4" cols="50" placeholder="设置您的签名(๑′ᴗ‵๑)"></textarea>
                    </div>
                </li>
                <li>
                    性别：<span id="sex"></span>
                </li>
                <li>
                    姓名：<span id="name"></span>
                </li>
                <li>
                    年龄：<sapn id="age"></sapn>
                </li>
                <li>
                    学号：<span id="num"></span>
                </li>
                <li>
                    卡号：<span id="number"></span>
                </li>
                <li>
                    余额：<span id="money"></span>
                </li>
                <li>
                    可借图书总数：<span id="book"></span>
                </li>
                <li>可借图书类型：<span id="type"></span></li>
                <li>
                    生效日期：<span id="time"></span>
                </li>
            </ul>
        </div>
    </div>
</body>
<script src="js/jquery-3.6.0.min.js"></script>
<script>
    if(localStorage.getItem("Token") == ""){
        localStorage.clear()
        window.location = "login.html"
    }else{
        $.ajax({
            type:"get",
            url:"http://120.76.130.104:9000/user/getMessage",
            data:{},
            headers:{
                //给gxp的数据
                Token:localStorage.getItem("Token")
            },
            success:function (data,text,xmlHttp){
                if (xmlHttp.getResponseHeader("Token") == "timeOut" || xmlHttp.getResponseHeader("Token") == "false") {
                    alert(xmlHttp.getResponseHeader("Token"))
                    localStorage.clear()
                    window.location = "login.html"
                }else {
                    if (data.code === '001'){
                        //存储他给我的数据
                        console.log(data)
                        localStorage.setItem("Token",xmlHttp.getResponseHeader("Token"))
                        $("#user").html(data.data.account)
                        $("#name").html(data.data.name)
                        $("#age").html(data.data.age)
                        $("#num").html(data.data.gardeNumber)
                        $("#number").html(data.data.cardNumber)
                        $("#money").html("￥"+data.data.money)
                        $("#time").html(data.data.startTime+"~"+data.data.endTime)
                        $("#level").html(data.data.level)
                        $("#sex").html(data.data.sex)
                        $("#book").html(data.data.count)
                        const user = data.data.book
                        var s = ""
                        for(var key in user){
                            console.log(key +":"+ user[key])
                            var types = key +":"+ user[key]
                            s = s + types +" "
                        }
                        $("#type").html(s)
                    }
                }
            }
        })
    }

</script>
</html>